<?php
class userActions extends Actions  
{	
	public $authlogin;
	public function __construct(){		
		$this->addJs(MVC_WWW_HOST.'js/jquery/jquery.js');		
		$authcode = Files::configLoad('authcode', MVC_ROOT_DIR.'/config/setting.inc');
		$this->assign('authlogin', $authcode['authlogin']);
		$this->authlogin = $authcode['authlogin'];
		$this->noCache();
		
	}
	
	
	public function actionsIndex(){
		session_destroy();
		$this->addJs(MVC_WWW_HOST.'js/user/login.js');
		$this->assign('title','理管理平台');
		
		//$this->layout();		
		
	}
	public function actionsLogout(){
			
		session_destroy();
		$this->redirect('admin.php/admin/user');		
		die();
	}
	
	public function actionsLogin()
	{	
		
		if (!$_POST) $this->redirect();
		$username  = Http::post('username');
		$password  = Http::post('password');
		if ($this->authlogin){
			$checkcode = Http::post('checkcode');		
			if (strtolower($checkcode)!=strtolower(@$_SESSION['captcha'])){
				die('-1');
			}	
		}	
		Files::factory('AdminUser');
		$user = new AdminUser();
		
		echo $user->checkUserLoginByUsername($username,$password);			
			
		die();	
	}
}
